package com.zx.cloud.controller;

import io.swagger.annotations.ApiOperation;

import java.util.ArrayList;
import java.util.List;
import java.util.Random;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import com.zx.cloud.ApiVersion;
import com.zx.cloud.RequestLogging;
import com.zx.cloud.common.auth0.jwt.Token;
import com.zx.cloud.common.filter.IgnoreAuth;
import com.zx.cloud.controller.client.ConsultationClient;
import com.zx.cloud.domain.ClientContact;
import com.zx.cloud.domain.Consultation;
import com.zx.cloud.model.response.ObjectDataResponse;
import com.zx.cloud.util.Page;

@RestController
@RequestMapping(value = ApiVersion.API_V1_PREFIX + "/consultation", produces = { MediaType.APPLICATION_JSON_UTF8_VALUE }, consumes = { MediaType.APPLICATION_JSON_UTF8_VALUE })
public class ConsultationController {

	@Autowired
	private ConsultationClient consultationClient;

	@IgnoreAuth
	@ApiOperation(value = "查看公告表内容", notes = "查看公告表内容")
	@RequestMapping(value = "queryConsultationApi", method = RequestMethod.POST)
	@ResponseBody
	public ObjectDataResponse<Page<Consultation>> queryConsultationApi(
			@RequestBody Consultation consultation) {
		consultation.setStatus(0);
		return consultationClient.queryConsultationApi(consultation);
	}

	@IgnoreAuth
	@RequestLogging
	@ApiOperation(value = "随机生成数据", notes = "随机生成数据")
	@RequestMapping(value = "randomApi", method = RequestMethod.POST)
	@ResponseBody
	public ObjectDataResponse<List<String>> resprandomApi() {

		String[]  money = {"1000","1100","1200","1300","1400","1500"};
		
		Random ran = new Random();
        List<String>  list =  new ArrayList<String>();
		for (int i = 0; i < 4; i++) {
			list.add("尾号 "+ (ran.nextInt(9000)+1000)+"用户,成功申请"+money[ran.nextInt(6)]+"元!");
			list.add("尾号 "+ (ran.nextInt(9000)+1000)+"用户,成功提额"+money[ran.nextInt(6)]+"元!");
			list.add("尾号 "+ (ran.nextInt(9000)+1000)+"用户,还款成功!");
		}
		
		return new ObjectDataResponse<List<String>>(list);
	}

}
